<template>
  <avue-form ref="avueForm" :option="tableOption" v-model="formModel"></avue-form>
</template>
<script>

import sysDataTableConfigOption from "@/option/start/development/sysDataTableConfigOption";
import {deepClone} from "utils/util";

export default {
  name: "editTableBase",
  props: {
    boxType: {
      type: String,
      default: 'add'
    },
    formModelData: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  computed: {
    tableOption() {
      let option = sysDataTableConfigOption();
      if ('detail' === this.boxType) {
        option.detail = true;
      }
      option.boxType = this.boxType;
      option.menuBtn = false
      return option
    }
  },
  data() {
    return {
      formModel: this.formModelData
    }
  },
  created() {

  },
  methods: {
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs.avueForm.validate((valid, done, err) => {
          if (valid) {
            resolve( deepClone(this.formModel))
            return
          }
          reject(err)//注意这个地方是错误消息
        })
      })
    },
    restValidate() {
      this.$refs.avueForm.hide()
    }
  }
}
</script>
<style scoped>

</style>
